#pragma once

class CriticalUnit
{
	private:

	BOOL bEnteredCriticalSection;

	public:

	CriticalUnit()
	{
		bEnteredCriticalSection = FALSE;
	}

	~CriticalUnit()
	{
		if(bEnteredCriticalSection)
			LeaveCriticalSection(&Vars.cCmdUnitSection);
	}

	VOID EnterSection()
	{
		bEnteredCriticalSection = TRUE;
		EnterCriticalSection(&Vars.cCmdUnitSection);
	}

	VOID LeaveSection()
	{
		bEnteredCriticalSection = FALSE;
		LeaveCriticalSection(&Vars.cCmdUnitSection);
	}
};
